package com.zbkj.front.controller.v2.user;

import com.zbkj.dal.base.result.CommonResult;
import com.zbkj.service.model.front.req.user.UnbindBankReq;
import com.zbkj.service.model.front.vo.CustomerServiceVO;
import com.zbkj.service.model.front.req.user.BindBankcardReq;
import com.zbkj.service.model.front.vo.user.BankInfoVO;
import com.zbkj.service.model.front.vo.user.UserInfoVO;
import com.zbkj.service.model.front.vo.user.UserLevelRecordVO;
import com.zbkj.front.service.user.UserV2Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Nullable;
import javax.annotation.Resource;
import java.util.List;

@Api("用户信息v2")
@Slf4j
@RestController
@RequestMapping("/api/front/v2/user")
public class UserV2Controller {

    @Resource
    private UserV2Service userV2Service;

    @ApiOperation(value = "查询用户会员信息", tags = "我的")
    @GetMapping("/member/info")
    public CommonResult<UserInfoVO> memberInfo() {
        return CommonResult.success(userV2Service.memberInfo());
    }

    @ApiOperation(value = "用户银行卡列表", tags = {"雅识账户"})
    @GetMapping("/bank/info")
    public CommonResult<BankInfoVO> bankInfo() {
        return CommonResult.success(userV2Service.userBank());
    }

    @ApiOperation(value = "添加银行卡", tags = {"雅识账户"})
    @PostMapping(value = "/bank/add")
    public CommonResult<Void> addBankInfo(@RequestBody BindBankcardReq req) {
        userV2Service.addBankInfo(req);
        return CommonResult.success();
    }

    @ApiOperation(value = "解绑银行卡", tags = {"雅识账户"})
    @PostMapping(value = "/bank/unbind")
    public CommonResult<Void> unbindUserBank(@RequestBody UnbindBankReq req) {
        userV2Service.unbindUserBank(req);
        return CommonResult.success();
    }

    @ApiOperation(value = "用户会员记录", notes = "如果userId为空。查询当前用户", tags = "推广")
    @GetMapping("/level/record")
    public CommonResult<List<UserLevelRecordVO>> userLevelRecord(@RequestParam("userId") @Nullable Integer userId) {
        return CommonResult.success(userV2Service.userLevelRecord(userId));
    }

    @ApiOperation(value = "用户客服信息", tags = "客服")
    @GetMapping("/customer/service")
    public CommonResult<CustomerServiceVO> customerService() {
        return CommonResult.success(userV2Service.customerService());
    }

}
